﻿using DaphneProfiBase;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;

namespace DaphneForms.ViewModel
{
    /// <summary>
    /// Returned value - saving type
    /// </summary>
    public enum eSaveType { SaveToFile, AppendToLibrary, DontSave, Cancel };

    /// <summary>
    /// Game Saving Form View Model
    /// </summary>
    public class GameSaveFormVM : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the GameSaveFormVM class.
        /// </summary>
        public GameSaveFormVM()
        {
            Result = eSaveType.Cancel;
            AppendToLibrary = false;
            SaveToFile = true;

            // create commands
            Yes = new RelayCommand(() =>
                {
                    Result = AppendToLibrary == true ? eSaveType.AppendToLibrary : eSaveType.SaveToFile;
                    CloseForm();
                });
            No = new RelayCommand(() =>
                {
                    Result = eSaveType.DontSave;
                    CloseForm();
                });
            Cancel = new RelayCommand(() =>
                {
                    Result = eSaveType.Cancel;
                    CloseForm();
                });
        }

        public RelayCommand Yes
        { get; set; }

        public RelayCommand No
        { get; set; }

        public RelayCommand Cancel
        { get; set; }

        public bool AppendToLibrary
        { get; set; }

        public bool SaveToFile
        { get; set; }

        /// <summary>
        /// Form Result
        /// </summary>
        public eSaveType Result
        { get; set; }

        /// <summary>
        /// Closes the form
        /// </summary>
        private void CloseForm()
        {
            // send message to close the form
            Messenger.Default.Send<NotificationMessage>(new NotificationMessage(Notify.SaveGameFormClose));
        }


    }
}